package com.sxbbc.common.basics.enums;

import java.util.ArrayList;
import java.util.List;

import com.sxbbc.common.basics.utils.calculation.CalcuUtils;

/**
 * 会员注册/登录渠道 包含订单下单渠道
 * @author arno
 *
 */
public enum LoginChannelEnums {

	APP(1,"APP",true),
	WX(2,"微信",true),
	PC(3,"PC",true),
	WAP(4,"Wap",false),
	PROGRAM(5,"小程序",true);
	
	private Integer channel;
	private String name;
	private Boolean valid;
	
	public Integer getChannel() {
		return channel;
	}
	public void setChannel(Integer channel) {
		this.channel = channel;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Boolean getValid() {
		return valid;
	}
	public void setValid(Boolean valid) {
		this.valid = valid;
	}
	
	private LoginChannelEnums(Integer channel,String name, Boolean valid) {
		this.channel=channel;
		this.name=name;
		this.valid=valid;
	}
	
	public static String getName(Integer channel) {
		String name="";
		for(LoginChannelEnums channelEnums:LoginChannelEnums.values()) {
			if(CalcuUtils.getInstance().isEquals(channelEnums.getChannel(), channel)) {
				name=channelEnums.getName();
				break;
			}
		}
		return name;
	}

	public static LoginChannelEnums getLoginEnum(int loginChannel){
		switch (loginChannel){
			case 1:
				return APP;
			case 2:
				return WX;
			case 3:
				return PC;
			case 4:
				return WAP;
			case 5:
				return PROGRAM;
			default:
				return null;
		}
	}
	
	public static List<LoginChannelEnums> queryValidList(){
		List<LoginChannelEnums> list=new ArrayList<LoginChannelEnums>();
		for(LoginChannelEnums o: LoginChannelEnums.values()){
			if (o.getValid()) {
				list.add(o);
			}
		}
		return list;
	}
	
}
